package com.socket.server.utils;


public class FmTask {

    public static String whitelistStr = "879,887,899,909,914,934,940,947,959,972,977,981,990,1001,1003,1009,1017,1025,1027,1037,1051,1057,1065,1067,1072,1077,962,887,1025,955";
    public static String graylistStr = "1079,1078,1076,1075,1074,1073,1071,1070,1069,1068,1066,1064,1063,1062,1061,1060,1059,1058,1056,1055,1054,1053,1052,1050,1049,1048,1047,1046,1045,1044,1043,1042,1041,1040,1039,1038,1036,1035,1034,1033,1032,1031,1030,1029,1028,1026,1024,1023,1022,1021,1020,1019,1018,1016,1015,1014,1013,1012,1011,1010,1008,1007,1006,1005,1004,1002,1000,999,997,996,995,994,993,992,988,987,986,985,983,982,980,979,978,976,975,974,973,970,969,968,967,966,965,964,961,960,958,957,956,954,953,952,951,950,949,946,945,944,943,942,941,939,938,937,936,935,933,931,930,929,928,927,926,925,924,923,922,921,920,918,917,916,912,911,910,908,907,906,905,904,903,902,901,898,897,896,895,894,893,892,891,890,889,888,886,885,884,883,882,881,880,878,877,876,875,874,873,871,870";
    public static long recordSeconds = 30; //默认录音时长30秒
    public static long scanSeconds = 60+10; //默认扫台时长70秒
    public static long period_seconds = 30*60;  //默认周期任务30分钟
    public static long whiteFreqRecordTimes = 12;  // 白名单电台录音次数，设置为每6个周期录音1次
    public static long grayFreqRecordTimes = 3;  // 灰名单电台录音次数，设置为每2个周期录音1次
    public static long illgaFreqRecordTimes = 1;  // 非法电台录音次数，设置为每1个周期录音1次
    public static String scanFrequencys = "[[87.0,108.0]]"; //频率范围
    public static float[][] scan_rang = parseFrequecys(scanFrequencys);
    public static boolean isNeedRecording = true; //默认设置录音
    public static boolean isPeriodTask = true; //默认设置周期任务
    public static long record_length = 30;	//对单个频率录音,默认录音时长30秒
    public static String taskId = "1";
    public static int start_hour = 4; //每日启动时间
    public static int start_minite = 0; //每日启动时间
    public static int start_second = 0; //每日启动时间
    public static int end_hour = 3; //每日结束时间
    public static int end_minite = 27; //每日结束时间
    public static int end_second = 0; //每日结束时间
    public static String CMD_FM_SCAN = "scanfreqs";
    public static String CMD_FM_TUNE = "tune";
    public static String CMD_FM_RECORD = "recording";

    /**
     * @param freq_range
     * @return
     */
    private static float[][] parseFrequecys(String freq_range) {
        float[][] ret_freqs;
        if (freq_range.indexOf("],[") == -1) {
            ret_freqs = new float[1][2];
            ret_freqs[0] = parseFreqs(freq_range);
            return ret_freqs;
        }
        String[] ranges = freq_range.split("\\]\\,\\[");
        ret_freqs = new float[ranges.length][2];
        for (int i = 0; i < ranges.length; i++) {
            ret_freqs[i] = parseFreqs(ranges[i]);
        }
        return ret_freqs;
    }

    private static float[] parseFreqs(String freq_range) {
        String freq = freq_range.replaceAll("\\[", "").replaceAll("\\]", "");
        if (freq.indexOf(",") == -1) {
            float[] ret_ = { Float.valueOf(freq), Float.valueOf(freq) };
            return ret_;
        }
        String[] ranges = freq.split(",");
        float minFreq = Float.valueOf(ranges[0]);
        float maxFreq = Float.valueOf(ranges[1]);
        float[] cur_freqs = { minFreq, maxFreq };
        return cur_freqs;
    }

}
